# -*- coding: utf-8 -*-
import scrapy
from e_n_proxy.items import ENProxyItem
from lxml import etree
from bs4 import BeautifulSoup
import re

class EProxySpider(scrapy.Spider):
    name = 'e_proxy'
    allowed_domains = ['www.89ip.cn']

    def start_requests(self):
        start_urls = []

        for i in range(1, 6):
            start_urls.append('http://www.89ip.cn/index_%d.html' % i)
        for i in start_urls:
            print(i,'============================================================')
            yield scrapy.Request(url=i,callback=self.parse)

    def parse(self, response):
        item = ENProxyItem()
        # html = etree.HTML(response.text)
        # print(response.text,'+++++++++++++++++++++++++++')
        # data = html.xpath('/html/body/meta"utf-8"/div[4]/div[1]/div/div[1]/table/tbody/tr[1]/td[1]/text()')

        print(re.findall("\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}",response.text),'+++++++++++')

        # （\d{0, 3}\.）{3}\d{0,3}\.
